/*
* JSA mixin plugin
*
* Mixin is a mechanism for code reuse
*
* To implement mixins, the 'mixin' property is used and expected array of mixing objects.
*
* Example:
*
* App.MixinA = {
*     propertyA: "propertyA"
* };
* App.MixinB = {
*     propertyB: "propertyB"
* };
* App.Silo = function() {
*     return {
*         mixin: [ App.MixinA, App.MixinB ],
*         ownPropery: "Own property"
*     }
* };
* var module = App.Silo.createInstance();
* module.ownPropery is defined
* module.propertyA is defined
* module.propertyB is defined
*
* @package JSA.Mixin
* @author sheiko
* @version jsa.mixin.js, v 2.0
* @license MIT
* @copyright (c) Dmitry Sheiko http://www.dsheiko.com
* Code style: http://docs.jquery.com/JQuery_Core_Style_Guidelines
*/
var jsa = jsa || {};
(function( jsa, undefined ) {
   /**
    * Extends object factory with traits support
    */
    jsa.Hook = jsa.Hook || [];
    jsa.Hook.push(function( instance, args ) {
        if ( instance.mixin && jsa.isArray( instance.mixin ) ) {
            for (var i = 0, len = instance.mixin.length; i < len; i++ ) {
                var trait = instance.mixin[ i ];
                for (var member in trait) {
                    if ( trait.hasOwnProperty( member ) ) {
                        instance[ member ] = trait[ member ];
                    }
                }
            }
        }
    });

}(jsa));